package com.teamone.etl.systemsettings.controller;


import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.teamone.etl.systemsettings.entity.Post;
import com.teamone.etl.systemsettings.service.PostService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (Post)表控制层
 *
 * @author makejava
 * @since 2021-01-20 14:24:34
 */
@RestController
@RequestMapping("post")
public class PostController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private PostService postService;

    /**
     * 通过id 进行但数据查询
     *
     * @param id  id
     * @return  单条数据
     */
    @GetMapping("/selectOne")
    public R selectOne(Integer id) {
        return success(postService.selectOne(id));
    }

    /**
     * 添加职位
     *
     * @param post 前台接受参数
     * @return true false
     */
    @PostMapping("/createPost")
    public R createPost(@RequestBody Post post) {
        Boolean post1 = postService.createPost(post);
        return success(post1);
    }

    /**
     * 查询岗位总人数
     *
     * @param id 岗位id
     * @return 岗位人数
     */
    @GetMapping("/getCountNumber")
    public R getCountNumber(Integer id){
        Integer countNumber = postService.getCountNumber(id);
        return success(countNumber);
    }
}